#include "StdAfx.h"
#include "ConsumerPolicyModel.h"


ConsumerPolicyModel::ConsumerPolicyModel(void)
{
	m_id = -1;
	m_consumerID = -1;
	m_policyCompany = -1;
	m_policyTime = -1;
	m_yearPaySum = _T("");
	m_isFuxiao = -1;
	m_policyPerson = -1;
}

ConsumerPolicyModel::~ConsumerPolicyModel(void)
{
}

void ConsumerPolicyModel::parseFromJson(Json::Value& jsonData)
{
	if (!jsonData["policyCom"].isNull()) 
	{
		this->m_policyCompany = jsonData["policyCom"].asInt();
	}
	if (!jsonData["policyTime"].isNull()) 
	{
		this->m_policyTime = jsonData["policyTime"].asInt();
	}
	CUtils::getJsonStringField(jsonData, "yearPayMoney", m_yearPaySum);
	if (!jsonData["isFuxiao"].isNull()) 
	{
		this->m_isFuxiao = jsonData["isFuxiao"].asInt();
	}
	if (!jsonData["policyMan"].isNull()) 
	{
		this->m_policyPerson = jsonData["policyMan"].asInt();
	}
}

void ConsumerPolicyModel::toJson(Json::Value& jsonData)
{
	if (this->m_policyCompany >= 0) 
	{
		jsonData["policyCom"] = this->m_policyCompany;
	}
	if (this->m_policyTime >= 0) 
	{
		jsonData["policyTime"] = this->m_policyTime;
	}
	if (this->m_yearPaySum.GetLength() > 0) 
	{
		jsonData["yearPayMoney"] = this->m_yearPaySum.GetBuffer();
	}
	if (this->m_isFuxiao >= 0) 
	{
		jsonData["isFuxiao"] = this->m_isFuxiao;
	}
	if (this->m_policyPerson >= 0) 
	{
		jsonData["policyMan"] = this->m_policyPerson;
	}
}